<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/16
 * Time: 17:21
 */

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class ShopOrderComment extends Model {
	/**
	 * 订单表详情
	 * @var string
	 */
	protected $table = 'shop_order_comment';
	protected $fillable = [
		'id',
		'uid',
		'orderid',
		'goodsid',
		'price',
		'goodsname',
		'number',
	];

	/**
	 * 添加
	 * @param array $order
	 * @return bool|int
	 */
	public function add_order_comment($order = array()) {
		if (empty($order)) {
			return false;
		}
		$rico = $this->insertGetId($order);
		if ($rico) {
			return $rico;
		} else {
			return false;
		}
	}

	/**
	 * 获取订单商品
	 * @param null $order_id
	 * @param null $uid
	 * @return array|bool
	 */
	public function get_order_comment($order_id = null, $uid = null) {
		$table = $this->where(['orderid' => $order_id]);
		if ($uid) {
			$table = $table->where(['uid' => $uid]);
		}
		$rico = $table->get()->toArray();
		if ($rico) {
			return $rico;
		} else {
			return false;
		}
	}

	/**
	 * 查询订单详情
	 * @param null $id
	 * @return array|bool
	 */
	public function find_order($id = null) {
		$rico = $this->where(['orderid' => $id])->get();
		if ($rico) {
			return $rico;
		} else {
			return false;
		}
	}

}